package com.kuang.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description: 商品类，用于承接从京东解析到的数据
 * @author: wuhaohua
 * @date: Created in 2022/4/10 20:16
 * @version: 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Commodity {
    private String id;
    private String title;
    private String img_url;
    private String price_str;
    private Double price;

    public void setPrice_str(String price_str) {
        this.price_str = price_str;
        if (this.price_str != null && !this.price_str.trim().equals("")) {
            this.price = Double.valueOf(price_str);
        }
    }

    public void setPrice(Double price) {
        this.price = price;
        this.price_str = String.format("%.2f", this.price);
    }
}
